package com.zhicheng.mapper;

import com.zhicheng.pojo.Order;
import com.zhicheng.pojo.vo.OrderVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper {

    @Insert("insert into orders(id, order_status,goods_id, user_id, user_name, address_book_id, consignee, phone, address, order_time, checkout_time, pay_channel, pay_type, pay_status, total_num, total_price, pay_amount, post_fee, delivery_time_type, pay_latest_time, create_time) " +
            "values (#{id},#{orderStatus},#{goodsId},#{userId},#{userName},#{addressBookId},#{consignee},#{phone},#{address},#{orderTime},#{checkoutTime},#{payChannel},#{payType},#{payStatus},#{totalNum},#{totalPrice},#{payAmount},#{postFee},#{deliveryTimeType},#{payLatestTime},#{createTime})")
    void creOrder(Order order);

    @Select("select * from orders where id =#{id} ;")
    Order getByOrderId(String id);

    void updateById(Order order);

    List<OrderVO> getByUserId(Long userId, Integer orderStatus);

    @Update("update orders set order_status = #{orderStatus} where id = #{id}")
    void updateOrderStatus(OrderVO order);
}
